<?php if ($readerSurvey != null) { ?>
<div class="newly " style="margin-top:10px;">
    <script type="text/javascript">
        $(document).ready(function() {
            // bind 'myForm' and provide a simple callback function
            var options = {
                data: { survey_id: '<?php echo $readerSurvey->getId() ?>'},
                success:    function() {
                    alert('提交成功!');
                }
            };
            $('#reader_survey_form').ajaxForm(options);
        });
    </script>
    <div class="newly_tit">
        <div class="com_tit">读者调查<span>SURVEY</span></div>
    </div>
    <form action="<?php echo url_for('onlineSurvey/postReaderSurvey') ?>" method="post" name="reader_survey_form"
          id="reader_survey_form">
        <!--        <input type="hidden" id="survey_id">-->

        <div class="questioncontent">
            <?php
            $idx = 1;
            $surveyId = $readerSurvey->getId();
            echo ' <input type="hidden" id="survey_id" value="' . $surveyId . '" >';
            foreach ($readerSurvey->getQuestions() as $q) {
                $questionId = $q->getId();
                $itemId = $surveyId . '_' . $questionId;
                $content = $q->getContent();
                $options = preg_split('/[\n]/', $content, -1, PREG_SPLIT_NO_EMPTY);

                echo ' <p>' . $idx . '.' . $q->getTitle() . '</br>';
                switch ($q->getType())
                {
                    case "单选":
                        foreach ($options as $option) {
                            $option = trim($option);
                            echo '<input type="radio" value="' . $option . '" name="' . $itemId . '">' . $option . '&nbsp';
                        }
                        break;
                    case "多选":
                        foreach ($options as $option) {
                            echo '<input type="checkbox" value="' . $option . '" name="' . $itemId . '[]">' . $option . '&nbsp';
                        }
                        break;
                    case "文本":
                        echo '<label><input type="text" class="input3" name="' . $itemId . '" id="' . $itemId . '"></label>' . '&nbsp';
                        break;
                }
                echo '</p>';
                $idx++;
            }
            ?>



            <div class="survey_submit">
                <input type="submit" class="ask_submit" value="提交" name="submit">&nbsp;&nbsp;&nbsp;
                <!--                <input type="submit" class="ask_submit" value="重置" id="button" name="button">-->
            </div>
        </div>

    </form>

</div>
<?php } ?>